﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Service
{
    internal class DepositeThroughParser : ICommand
    {
        DataLayer.DBFacade DB;
        Model.Account account;
        double amount;

        public DepositeThroughParser(Model.Account account, double amount)
        {
            DB = new DataLayer.DBFacade();
            this.account = account;
            this.amount = amount;
        }

        public bool Execute()
        {
            string query = "SP_Withdraw 'D'," + account.AccountNumber + "," + account.PIN + "," + amount;
            return DB.Execute(query) > 0;
        }

        public bool Undo()
        {
            string query = "SP_Withdraw 'W'," + account.AccountNumber + "," + account.PIN + "," + amount;
            return DB.Execute(query) > 0;
        }
    }
}